//
//  GameData.h
//  Agility
//
//  Created by Dominique d'Argent on 15.03.11.
//  Copyright 2011 Nicky Nubbel. All rights reserved.
//

#import <Foundation/Foundation.h>

enum {
    GameStateReady      = 0x01,
    GameStateRunning    = 0x02,
    GameStateStopped    = 0x03
};
typedef NSUInteger GameState;

@class GameObject;
@class SceneryObject;

// GameData
//
// This class controls the game loop and manages all game objects.
// It is responisble for updating every game objects in a specified time interval
// and for detection and handling collisions.
//
@interface GameData : NSObject {
    GameState state;
    CGSize size;
    NSMutableDictionary *gameObjects;
    NSTimer *timer;
    NSDate *lastUpdate;
    CGPoint touchPoint;
    CGFloat score;
}

@property (nonatomic) GameState state;
@property (nonatomic, readonly) CGSize size;
@property (nonatomic, readonly) NSMutableDictionary *gameObjects;
@property (nonatomic) CGPoint touchPoint;
@property (nonatomic) CGFloat score;

+ (GameData *)sharedGameData;

- (void)addGameObject:(GameObject *)newGameObject forKey:(NSString *)gameObjectKey;
- (void)removeGameObjectForKey:(NSString *)gameObjectKey;
- (GameObject *)gameObjectForKey:(NSString *)gameObjectKey;
- (NSString *)keyForTurretAtIndex:(NSUInteger)index;
- (NSString *)keyForNextShot;
//- (NSString *)keyForNextSceneryObject;
- (void)detectAndHandleCollisions;
- (void)addSceneryObject:(SceneryObject *)newSceneryObject;
- (void)start;
- (void)stop;
- (void)update;

@end

// notifications
extern NSString *GAME_OBJECT_NEW_NOTIFICATION; 
extern NSString *GAME_SCENERY_OBJECT_NEW_NOTIFICATION; 
extern NSString *GAME_OVER_NOTIFICATION; 

// keys
extern NSString *GAME_PLAYER_KEY;
extern NSString *GAME_TURRET_KEY_BASE;
extern NSString *GAME_SHOT_KEY_BASE;
extern NSString *GAME_SCENERY_KEY_BASE;

// config
extern const NSTimeInterval GAME_UPDATE_DURATION;